<template>
  <div class="app-container foSi14">
    <el-table
      key="table0"
      v-loading="listLoading"
      class="mar-top20 wid100"
      :data="list"
      stripe
      :row-style="{ background: '#f2f2f2' }"
    >
      <div slot="empty" class="m-empty-box">
        <div class="mar" style="width: 168px;height: 180px;">
          <img src="https://www.jianyigongxiang.com/public/membercard/empty.png" class="wh100">
        </div>
        <div class="title">暂无数据</div>
      </div>
      <el-table-column prop="name" label="场馆名称" width="120" />
      <el-table-column prop="num" label="分发条数" width="120" />
      <el-table-column prop="message_num_all" label="场馆总分发条数" width="120" />
      <el-table-column prop="message_num" label="场馆剩余条数" width="120" />
      <el-table-column prop="admin_message_num" label="品牌端剩余条数" width="120" />
      <el-table-column prop="createtime" label="分发时间" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="getList"
    />
  </div>
</template>

<script>
// import fetchList from '@/api/article'
import Pagination from '@/components/Pagination'
import {
  getXuan
} from '@/utils/limits.js'
import {
  mapGetters
} from 'vuex' // Secondary package based on el-pagination
import {
  distributeLog
} from '@/api/sms2'
export default {
  name: 'ArticleList',
  components: {
    Pagination
  },
  data() {
    return {
      id: 0,
      list: null,
      total: 0,
      listLoading: false,
      listQuery: {
        page: 1,
        limit: 10
      }
    }
  },
  computed: {
    ...mapGetters([
      'permission_routes',
      'roles'
    ])
  },
  created() {
    var query = this.$route.query
    this.id = query.id
    var xuanList = [{
      name: '分发记录',
      url: '/sms2/distributeLog',
      pd: true
    }]
    var xuanList1 = getXuan(xuanList, this.roles)
    this.$store.dispatch('user/changeXuan', {
      key: 'xuanList',
      value: xuanList1
    })
    this.$store.dispatch('user/changeXuan', {
      key: 'xuan',
      value: 0
    })
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      distributeLog({
        'id': this.id,
        'page': this.listQuery.page,
        'limit': this.listQuery.limit
      }).then(response => {
        const {
          data
        } = response
        console.log(data)
        this.total = data.total
        this.list = data.data
        this.listLoading = false
      }).catch(error => {
        console.log(error)
        this.listLoading = false
      })
    }
  }
}
</script>

<style scoped>
.app-container {
  padding: 20px;
}
</style>
